package edu.ubb.remeye.communication;

/**
 * Enumeration of message types.
 * 
 * @author Andrew Ianicicau
 *
 */
public enum MessageType {

	///////////////////////////////////////////////////////////////////////////////////
	////		ATTRIBUTES - MessageType
	///////////////////////////////////////////////////////////////////////////////////

	/**
	 * Unknown message type.
	 */
	UNKNOWN,
	
	/**
	 * Message contains an identifier.
	 */
	IDENTIFIER,
	
	/**
	 * Message contains the security list.
	 */
	SECURITY_LIST,
	
	/**
	 * Message contains a security answer.
	 */
	SECURITY_ANSWER,
	
	/**
	 * Message contains authentication information.
	 */
	AUTHENTICATION,
	
	/**
	 * Message contains authentication result.
	 */
	AUTHENTICATION_RESULT,
	
	/**
	 * Message contains desired encoding.
	 */
	ENCODING,
	
	/**
	 * Message contains selected encoding.
	 */
	ENCODING_ANSWER,
	
	/**
	 * Message contains request for control.
	 */
	CONTROL_REQUEST,
	
	/**
	 * Message contains answer to control request.
	 */
	CONTROL_ANSWER,
	
	/**
	 * Message contains update request.
	 */
	UPDATE,
	
	/**
	 * Message contains data.
	 */
	DATA,
	
	/**
	 * Message contains events.
	 */
	EVENT;

	
	
	///////////////////////////////////////////////////////////////////////////////////
	////		METHODS - MessageType
	///////////////////////////////////////////////////////////////////////////////////
	
	/**
	 * Returns the MessageType associated to the given ordinal.
	 * @param ordinal MessageType ordinal.
	 * @return MessageType according to ordinal.
	 */
	public static MessageType getMessageType(int ordinal) {
		switch(ordinal) {
		case 0:
			return UNKNOWN;
		case 1:
			return IDENTIFIER;
		case 2:
			return SECURITY_LIST;
		case 3:
			return SECURITY_ANSWER;
		case 4:
			return AUTHENTICATION;
		case 5:
			return AUTHENTICATION_RESULT;
		case 6:
			return ENCODING;
		case 7:
			return ENCODING_ANSWER;
		case 8:
			return CONTROL_REQUEST;
		case 9:
			return CONTROL_ANSWER;
		case 10:
			return UPDATE;
		case 11:
			return DATA;
		case 12:
			return EVENT;
		default:
			return UNKNOWN;
		}
	}

}
